<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <body>

        <ui:composition template="./templates/basicTemplate.xhtml">
            <ui:define name="show_messages">

            </ui:define>

            <ui:define name="content">
                <h:form>
                    <p:panelGrid columns="1" style="width: 100%" cellpadding="5" rendered="#{login.loggedSystemAdmin}">  
                        <f:facet name="header">
                            <h:outputText value="Zobrazení"/>
                        </f:facet>
                        <f:facet name="footer">
                            <p:commandButton value="Dostupné" action="#{ticket.setDisplayMode(0)}" update="ticketList"/>
                            <p:commandButton value="Mnou řešené" action="#{ticket.setDisplayMode(1)}" update="ticketList"/>
                            <p:commandButton value="Všechny" action="#{ticket.setDisplayMode(2)}" update="ticketList"/>
                        </f:facet>
                    </p:panelGrid>
                    <br/>
                    <p:dataTable var="t" value="#{ticket.tickets}" widgetVar="ticketsTable" id="ticketList">  
                        <f:facet name="header">  
                            Výpis ticketů 
                        </f:facet> 
                        <p:column style=" text-align: left">
                            <f:facet name="header">
                                <h:outputText value="Nadpis" />
                            </f:facet>
                            <h:outputText value="#{t.title}" />
                        </p:column>
                        <p:column style="width:100px; text-align: center">
                            <f:facet name="header">
                                <h:outputText value="Zákazník" />
                            </f:facet>
                            <h:outputText value="#{t.createdBy}"/>
                        </p:column>
                        <p:column style="width:100px; text-align: center">
                            <f:facet name="header">
                                <h:outputText value="Řešitel" />
                            </f:facet>
                            <h:outputText value="#{t.solvedBy}"/>
                        </p:column>
                        <p:column style="width: 200px; text-align: center">
                            <f:facet name="header">
                                <h:outputText value="Datum a čas"/>
                            </f:facet>
                            <h:outputText value="#{t.created}">
                                <f:convertDateTime type="both" timeZone="CET" />
                            </h:outputText>
                        </p:column>
                        <p:column style="width: 200px; text-align: center">
                            <f:facet name="header">
                                <h:outputText value="Stav" />
                            </f:facet>
                            <h:outputText value="#{ticket.stringState(t)}" />
                        </p:column>
                        <p:column style="width: 50px; text-align: center">
                            <f:facet name="header">
                                <h:outputText value="Cena" />
                            </f:facet>
                            <h:outputText value="#{t.price}" />
                        </p:column>
                        <p:column style="width: 50px; text-align: center">
                            <p:commandButton icon="ui-icon-search" value="Zobrazit" action="#{ticket.editTicket(t)}" />
                        </p:column>
                    </p:dataTable>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
